import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '../layout'
 
//内网去掉
//import summaryRouter from './modules/summary'
 
/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    noCache: true                if set true, the page will no be cached(default is false)
    affix: true                  if set true, the tag will affix in the tags-view
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: '/404',
    component: () => import('@/pages/project/views/error-page/404'),
    hidden: true
  },
  {
    path: '/home-screen',
    component: () => import('@/pages/project/views/homescreen/HomeScreen.vue'),
    name: 'HomeScreen',
    hidden: true
  },
  {
    path: '/project-screen',
    component: () => import('@/pages/project/views/screen2/ProjectScreen.vue'),
    name: 'ProjectScreen',
    hidden: true,
    meta: {
      keepAlive: false
    
       
    },
  },
  {
    path: '/401',
    component: () => import('@/pages/project/views/error-page/401'),
    hidden: true
  },
  {
    path: '/tenancy',
    component: () => import('@/pages/project/views/tenancy/index'),
    name: 'tenancy',
    hidden: true
  },
  {
    path: '/dayin',
    component: () => import('@/pages/project/views/dayin/Erweima'),
    name: 'dayin',
    hidden: true
  },
  {
    path: '/dayin1',
    component: () => import('@/pages/project/views/dayin/Erweima1'),
    name: 'dayin1',
    hidden: true
  },
  {
    path: '/pdfreade',
    component: () => import('@/pages/project/views/dayin/PDFRead'),
    name: 'pdfreade',
    hidden: true
  },
 
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    meta: {
      icon: 'dashboard'
    },
    children: [
      {
        path: 'dashboard',
        component: () => import('@/pages/project/views/home/home.vue'),
        name: 'Dashboard',
        meta: { title: '首页', noCache: true, affix: true }
      },
    ]
  },
 
  {
    path: '/profile',
    component: Layout,
    redirect: '/profile/index',
    hidden: true,
    children: [
      {
        path: 'index',
        component: () => import('@/pages/project/views/profile/index'),
        name: 'Profile',
        meta: { title: 'profile', icon: 'user', noCache: true }
      }
    ]
  }
]

/**
 * asyncRoutes
 * the routes that need to be dynamically loaded based on user roles
 */
export const asyncRoutes = [
  // {
  //   path: '/permission',
  //   component: Layout,
  //   redirect: '/permission/page',
  //   alwaysShow: true, // will always show the root menu
  //   name: 'Permission',
  //   meta: {
  //     title: 'permission',
  //     icon: 'lock',
  //     roles: ['admin', 'editor'] // you can set roles in root nav
  //   },
  //   children: [
  //     {
  //       path: 'page',
  //       component: () => import('@/pages/project/views/permission/page'),
  //       name: 'PagePermission',
  //       meta: {
  //         title: 'pagePermission',
  //         roles: ['admin'] // or you can only set roles in sub nav
  //       }
  //     },
  //     {
  //       path: 'directive',
  //       component: () => import('@/pages/project/views/permission/directive'),
  //       name: 'DirectivePermission',
  //       meta: {
  //         title: 'directivePermission'
  //         // if do not set roles, means: this page does not require permission
  //       }
  //     },
  //     {
  //       path: 'role',
  //       component: () => import('@/pages/project/views/permission/role'),
  //       name: 'RolePermission',
  //       meta: {
  //         title: 'rolePermission',
  //         roles: ['admin']
  //       }
  //     }
  //   ]
  // },
  //
  // {
  //   path: '/icon',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'index',
  //       component: () => import('@/pages/project/views/icons/index'),
  //       name: 'Icons',
  //       meta: { title: 'icons', icon: 'icon', noCache: true }
  //     }
  //   ]
  // },

  /** when your routing map is too long, you can split it into small modules **/
  {
    path: '/plan',
    component: Layout,
    redirect: '/plan/manage',
    name: 'plan',
    meta: {
      title: '计划管理',
      icon: 'icon-plabgl'
    },
    children: [
      {
        path: 'plan',
        component: () => import('@/pages/project/views/plan/plan-info-manage.vue'),
        name: 'PlanInfoManage',
        meta: { title: '计划管理', noCache: true }
      }
    ]
  },
  {
    path: '/count',
    component: Layout,
    redirect: '/count/manage',
    name: 'count',
    meta: {
      title: '人员管理',
      icon: 'ico-personalstat'
    },
    children: [
      {
        path: 'member',
        component: () => import('@/pages/project/views/project/MemberManage.vue'),
        name: 'MemberManage',
        meta: { title: '成员管理', noCache: true }
      },
      {
        path: 'detectionUnit',
        component: () => import('@/pages/project/views/detectionUnit/index.vue'),
        name: 'DetectionUnit',
        meta: { title: '配合单位', noCache: true }
      },
      {
        path: 'dataType',
        component: () => import('@/pages/project/views/count/user-count-manage.vue'),
        name: 'UserCountInfo',
        meta: { title: '人员信息统计', noCache: true }
      },
      //内网去掉
      // {
      //   path: 'people',
      //   component: () => import('@/pages/project/views/count/AlarmPeople.vue'),
      //   name: 'AlarmPeople',
      //   meta: { title: '现场作业人数', noCache: true }
      // }
    ]
  },
  // {
  //   path: '/personnel',
  //   component: Layout,
  //   redirect: '/personnel/manage',
  //   name: 'personnel',
  //   meta: {
  //     title: '人员管理',
  //     icon: 'icon-xmxi'
  //   },
  //   children: [
  //     {
  //       path: 'member',
  //       component: () => import('@/pages/project/views/project/MemberManage.vue'),
  //       name: 'MemberManage',
  //       meta: { title: '成员管理', noCache: true }
  //     }
  //     // {
  //     //   path: 'department',
  //     //   component: () => import('@/pages/project/views/project/position-manage.vue'),
  //     //   name: 'department',
  //     //   meta: { title: '岗位管理', roles: ['superSysOpsAdmin', 'orgAdmin', 'superSysOpsAdmin'] }
  //     // },
  //   ]
  // },

  {
    path: '/alarm',
    component: Layout,
    redirect: '/alarm/event',
    name: 'Alarm',
    meta: {
      title: '智能终端',
      icon: 'sbgl'
    },
    children: [
      // {
      //   path: 'event',
      //   component: () => import('@/pages/project/views/equipment/AlarmEvent.vue'),
      //   name: 'AlarmEvent',
      //   meta: { title: '报警事件管理', noCache: true }
      // },
      // {
      //   path: 'history',
      //   component: () => import('@/pages/project/views/equipment/AlarmHistory.vue'),
      //   name: 'AlarmHistory',
      //   meta: { title: '历史数据管理', noCache: true }
      // },
      {
        path: 'facility',
        component: () => import('@/pages/project/views/equipment/facility-manage.vue'),
        name: 'FacilityManage',
        meta: { title: '设备信息管理', noCache: true }
      },
      // {
      //   path: 'pipe',
      //   component: () => import('@/pages/project/views/equipment/pipe-manage.vue'),
      //   name: 'PipeManage',
      //   meta: { title: '管材信息管理', noCache: true }
      // },
      // {
      //   path: 'welding',
      //   component: () => import('@/pages/project/views/equipment/welding-material-manage.vue'),
      //   name: 'WeldingMaterialManage',
      //   meta: { title: '焊材信息管理', noCache: true }
      // },
      {
        path: 'welded',
        component: () => import('@/pages/project/views/equipment/welded-joint-manage.vue'),
        name: 'WeldedJointManage',
        meta: { title: '焊口信息管理', noCache: true }
      }
    
    ]
  },
  {
    path: '/video',
    component: Layout,
    redirect: '/video/manage',
    name: 'project',
    meta: {
      title: '视频管理',
      icon: 'video-gl'
    },
    children: [
      {
        path: 'manage',
        component: () => import('@/pages/project/views/video/video-manage.vue'),
      
        name: 'VideoManage',
        meta: { title: '视频管理', noCache: true }
      }
    ]
  },

  {
    path: '/history',
    component: Layout,
    redirect: '/history/welder',
    name: 'history',
    meta: {
      title: '数据库',
      icon: 'lssjgl'
    },
    children: [
      {
        path: 'welder',
        component: () => import('@/pages/project/views/history/WelderHistory.vue'),
        name: 'welderHistory',
        meta: { title: '焊接数据', noCache: true }
      },
      // {
      //   path: 'safety',
      //   component: () => import('@/pages/project/views/history/SafetyHistory.vue'),
      //   name: 'safetyHistory',
      //   meta: { title: '安全历史数据', noCache: true }
      // },
      {
        path: 'environment',
        component: () => import('@/pages/project/views/history/EnvironmentHistory.vue'),
        name: 'environmentHistory',
        meta: { title: '安全数据', noCache: true }
      }
    ]
  },
  {
    path: '/patrol',
    component: Layout,
    redirect: '/patrol/manage',
    name: 'project',
    meta: {
      title: '巡检报警管理',
      icon: 'xjjlgl'
    },
    children: [
      // {
      //   path: 'manage',
      //   component: () => import('@/pages/project/views/patrol/patrol-manage.vue'),
      //   name: 'PatrolManage',
      //   meta: { title: '巡检管理' }
      // }
      {
        path: 'patrol',
        component: () => import('@/pages/project/views/patrol/patrol-type-manage.vue'),
        name: 'PatrolTypeManage',
        meta: { title: '巡检对象管理', noCache: true }
      },
      {
        path: 'manage',
        component: () => import('@/pages/project/views/patrol/PatrolLogs.vue'),
        name: 'PatrolManage',
        meta: { title: '巡检事件管理', noCache: true }
      },
      {
        path: 'event',
        component: () => import('@/pages/project/views/equipment/AlarmEvent.vue'),
        name: 'AlarmEvent',
        meta: { title: '报警事件管理', noCache: true }
      },
      {
        path: 'object',
        component: () => import('@/pages/project/views/equipment/AlarmObject.vue'),
        name: 'AlarmEvent',
        meta: { title: '报警对象管理', noCache: true }
      }
    ]
  },

  {
    path: '/weld',
    component: Layout,
    redirect: '/weld/identification',
    name: 'weld',
    meta: {
      title: '工艺管理',
      icon: 'icon-xmxi'
    },
    children: [
      {
        path: 'identification',
        component: () => import('@/pages/project/views/weld/IdentificationCard.vue'),
        name: 'identificationManage',
        meta: { title: '识别卡管理', noCache: true }
        // icon: 'sbkgl'
      },
      {
        path: 'groove',
        component: () => import('@/pages/project/views/groove/index.vue'),
        name: 'Groove',
        meta: { title: '坡口管理', noCache: true }
      }
      // {
      //   path:'welds',
      //   component:() => import('@/pages/project/views/weld/welds.vue'),
      //   name:'weldsManage',
      //   meta:{title:'焊缝施焊管理',noCache: true}
      // }
    ]
  },
  // detectionUnitRouter,
  // grooveRouter,
 
  //内网去掉
  //summaryRouter,
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  base: 'project',
  mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
